* Typo
[lhc/web/wiklou.git] / config / index.php
1 <?php
2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
4 # http://www.mediawiki.org/
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # http://www.gnu.org/copyleft/gpl.html
20
21 error_reporting( E_ALL );
22 header( "Content-type: text/html; charset=utf-8" );
23 @ini_set( "display_errors", true );
24
25 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 "http://www.w3.org/TR/html4/loose.dtd">
27 <html>
28 <head>
29 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
30 <meta name="robots" content="noindex,nofollow">
31 <title>MediaWiki installation</title>
32 <style type="text/css">
33 #credit {
34 float: right;
35 width: 200px;
36 font-size: 0.7em;
37 background-color: #eee;
38 color: black;
39 border: solid 1px #444;
40 padding: 8px;
41 margin-left: 8px;
42 }
43
44 dl.setup dd {
45 margin-left: 0;
46 }
47 dl.setup dd label.column {
48 clear: left;
49 font-weight: bold;
50 width: 12em;
51 float: left;
52 text-align: right;
53 padding-right: 1em;
54 }
55 dl.setup dt {
56 clear: left;
57 font-size: 0.8em;
58 margin-left: 10em;
59 /* margin-right: 200px; */
60 margin-bottom: 2em;
61 }
62 .error {
63 color: red;
64 }
65 ul.plain {
66 list-style: none;
67 clear: both;
68 margin-left: 12em;
69 }
70 </style>
71 </head>
72
73 <body>
74
75 <div id="credit">
76 <center>
77 <a href="http://www.mediawiki.org/">
78 <img src="../skins/common/images/mediawiki.png" width="135" height="135" alt="" border="0" />
79 </a>
80 </center>
81
82 <p><strong><a href="http://www.mediawiki.org/">MediaWiki</a></strong> is
83 Copyright (C) 2001-2005 by Magnus Manske, Brion Vibber, Lee Daniel Crocker,
84 Tim Starling, Erik M&ouml;ller, Gabriel Wicke and others.</p>
85
86 <ul>
87 <li><a href="../README">Readme</a></li>
88 <li><a href="../RELEASE-NOTES">Release notes</a></li>
89 <li><a href="../docs/">doc/</a></li>
90 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
91 </ul>
92
93 <p>This program is free software; you can redistribute it and/or modify
94 it under the terms of the GNU General Public License as published by
95 the Free Software Foundation; either version 2 of the License, or
96 (at your option) any later version.</p>
97
98 <p>This program is distributed in the hope that it will be useful,
99 but WITHOUT ANY WARRANTY; without even the implied warranty of
100 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101 GNU General Public License for more details.</p>
102
103 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
104 along with this program; if not, write to the Free Software
105 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
106 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
107 </div>
108
109 <?php
110
111 # Relative includes seem to break if a parent directory is not readable;
112 # this is common for public_html subdirs under user home directories.
113 #
114 # As a dirty hack, we'll try to set up the include path first.
115 #
116 $IP = dirname( dirname( __FILE__ ) );
117 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
118 ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" );
119
120 define( "MEDIAWIKI", true );
121 define( "MEDIAWIKI_INSTALL", true );
122 require_once( "includes/Defines.php" );
123 require_once( "includes/DefaultSettings.php" );
124 require_once( "includes/MagicWord.php" );
125 require_once( "includes/Namespace.php" );
126 ?>
127
128 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
129
130
131 <?php
132
133 /* Check for existing configurations and bug out! */
134
135 if( file_exists( "../LocalSettings.php" ) ) {
136 dieout( "<h2>Wiki is configured.</h2>
137
138 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
139
140 <p>(You should probably remove this directory for added security.)</p>" );
141 }
142
143 if( file_exists( "./LocalSettings.php" ) ) {
144 writeSuccessMessage();
145
146 dieout( '' );
147 }
148
149 if( !is_writable( "." ) ) {
150 dieout( "<h2>Can't write config file, aborting</h2>
151
152 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
153 writable by the web server. Once configuration is done you'll move the created
154 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
155 then remove the <tt>config</tt> subdirectory entirely.</p>
156
157 <p>To make the directory writable on a Unix/Linux system:</p>
158
159 <pre>
160 cd <i>/path/to/wiki</i>
161 chmod a+w config
162 </pre>" );
163 }
164
165
166 require_once( "install-utils.inc" );
167 require_once( "maintenance/updaters.inc" );
168
169 class ConfigData {
170 function getEncoded( $data ) {
171 # removing latin1 support, no need...
172 return $data;
173 }
174 function getSitename() { return $this->getEncoded( $this->Sitename ); }
175 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
176 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
177 }
178
179 ?>
180
181 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
182
183 <h2>Checking environment...</h2>
184 <ul>
185 <?php
186 $endl = "
187 ";
188 $wgNoOutputBuffer = true;
189 $conf = new ConfigData;
190
191 install_version_checks();
192
193 print "<li>PHP " . phpversion() . ": ok</li>\n";
194
195 if( ini_get( "register_globals" ) ) {
196 ?>
197 <li><b class='error'>Warning:</b> <strong>PHP's
198 <tt><a href="http://php.net/register_globals">register_globals</a></tt>
199 option is enabled.</strong> MediaWiki will work correctly, but this setting
200 increases your exposure to potential security vulnerabilities in PHP-based
201 software running on your server. <strong>You should disable it if you are able.</strong></li>
202 <?php
203 }
204
205 $fatal = false;
206
207 if( ini_get( "magic_quotes_runtime" ) ) {
208 $fatal = true;
209 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime</a> is active!</strong>
210 This option corrupts data input unpredictably; you cannot install or use
211 MediaWiki unless this option is disabled.
212 <?php
213 }
214
215 if( ini_get( "magic_quotes_sybase" ) ) {
216 $fatal = true;
217 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase</a> is active!</strong>
218 This option corrupts data input unpredictably; you cannot install or use
219 MediaWiki unless this option is disabled.
220 <?php
221 }
222
223 if( $fatal ) {
224 dieout( "</ul><p>Cannot install wiki.</p>" );
225 }
226
227 if( ini_get( "safe_mode" ) ) {
228 $conf->safeMode = true;
229 ?>
230 <li><b class='error'>Warning:</b> <strong>PHP's
231 <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
232 You may have problems caused by this, particularly if using image uploads.
233 </li>
234 <?php
235 } else {
236 $conf->safeMode = false;
237 }
238
239
240 $sapi = php_sapi_name();
241 $conf->prettyURLs = true;
242 print "<li>PHP server API is $sapi; ";
243 switch( $sapi ) {
244 case "apache":
245 case "apache2handler":
246 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
247 break;
248 case "cgi":
249 case "cgi-fcgi":
250 case "apache2filter":
251 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
252 $conf->prettyURLs = false;
253 break;
254 default:
255 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
256 }
257 print "</li>\n";
258
259 $conf->xml = function_exists( "utf8_encode" );
260 if( $conf->xml ) {
261 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
262 } else {
263 dieout( "PHP's XML module is missing; the wiki requires functions in
264 this module and won't work in this configuration.
265 If you're running Mandrake, install the php-xml package." );
266 }
267
268 $memlimit = ini_get( "memory_limit" );
269 $conf->raiseMemory = false;
270 if( empty( $memlimit ) || $memlimit == -1 ) {
271 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
272 } else {
273 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <strong>If this is too low, installation may fail!</strong> ";
274 $n = IntVal( $memlimit );
275 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
276 $n = IntVal( $m[1] * (1024*1024) );
277 }
278 if( $n < 20*1024*1024 ) {
279 print "Attempting to raise limit to 20M... ";
280 if( false === ini_set( "memory_limit", "20M" ) ) {
281 print "failed.";
282 } else {
283 $conf->raiseMemory = true;
284 print "ok.";
285 }
286 }
287 print "</li>\n";
288 }
289
290 $conf->zlib = function_exists( "gzencode" );
291 if( $conf->zlib ) {
292 print "<li>Have zlib support; enabling output compression.</li>\n";
293 } else {
294 print "<li>No zlib support.</li>\n";
295 }
296
297 $conf->turck = function_exists( 'mmcache_get' );
298 if ( $conf->turck ) {
299 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
300 }
301 $conf->eaccel = function_exists( 'eaccelerator_get' );
302 if ( $conf->eaccel ) {
303 $conf->turck = 'eaccelerator';
304 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
305 }
306 if (!$conf->turck && !$conf->eaccel) {
307 print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> are installed, " .
308 "can't use object caching functions</li>\n";
309 }
310
311 $conf->diff3 = false;
312 $diff3locations = array("/usr/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin") + explode(":", getenv("PATH"));
313 $diff3names = array("gdiff3", "diff3");
314
315 $diff3versioninfo = array('$1 --version 2>&1', 'diff3 (GNU diffutils)');
316 foreach ($diff3locations as $loc) {
317 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
318 if ($exe !== false) {
319 $conf->diff3 = $exe;
320 break;
321 }
322 }
323
324 if ($conf->diff3)
325 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
326 else
327 print "<li>GNU diff3 not found.</li>";
328
329 $conf->ImageMagick = false;
330 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
331 foreach( $imcheck as $dir ) {
332 $im = "$dir/convert";
333 if( file_exists( $im ) ) {
334 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
335 $conf->ImageMagick = $im;
336 break;
337 }
338 }
339
340 $conf->HaveGD = function_exists( "imagejpeg" );
341 if( $conf->HaveGD ) {
342 print "<li>Found GD graphics library built-in";
343 if( !$conf->ImageMagick ) {
344 print ", image thumbnailing will be enabled if you enable uploads";
345 }
346 print ".</li>\n";
347 } else {
348 if( !$conf->ImageMagick ) {
349 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
350 }
351 }
352
353 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
354
355 # $conf->IP = "/Users/brion/Sites/inplace";
356 $conf->IP = dirname( dirname( __FILE__ ) );
357 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
358
359 # $conf->ScriptPath = "/~brion/inplace";
360 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
361 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
362
363 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
364
365 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
366 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
367 ? 'root@localhost'
368 : $_SERVER["SERVER_ADMIN"];
369 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
370 $conf->DBtype = importPost( "DBtype", "mysql" );
371 $conf->DBserver = importPost( "DBserver", "localhost" );
372 $conf->DBname = importPost( "DBname", "wikidb" );
373 $conf->DBuser = importPost( "DBuser", "wikiuser" );
374 $conf->DBpassword = importPost( "DBpassword" );
375 $conf->DBpassword2 = importPost( "DBpassword2" );
376 $conf->DBprefix = importPost( "DBprefix" );
377 $conf->RootPW = importPost( "RootPW" );
378 $conf->LanguageCode = importPost( "LanguageCode", "en" );
379 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
380 $conf->SysopPass = importPost( "SysopPass" );
381 $conf->SysopPass2 = importPost( "SysopPass2" );
382
383 /* Check for validity */
384 $errs = array();
385
386 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
387 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
388 }
389 if( $conf->DBuser == "" ) {
390 $errs["DBuser"] = "Must not be blank";
391 }
392 if( $conf->DBpassword == "" ) {
393 $errs["DBpassword"] = "Must not be blank";
394 }
395 if( $conf->DBpassword != $conf->DBpassword2 ) {
396 $errs["DBpassword2"] = "Passwords don't match!";
397 }
398 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
399 $errs["DBprefix"] = "Invalid table prefix";
400 }
401
402 if( $conf->SysopPass == "" ) {
403 $errs["SysopPass"] = "Must not be blank";
404 }
405 if( $conf->SysopPass != $conf->SysopPass2 ) {
406 $errs["SysopPass2"] = "Passwords don't match!";
407 }
408
409 $conf->License = importRequest( "License", "none" );
410 if( $conf->License == "gfdl" ) {
411 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
412 $conf->RightsText = "GNU Free Documentation License 1.2";
413 $conf->RightsCode = "gfdl";
414 $conf->RightsIcon = '${wgStylePath}/common/images/gnu-fdl.png';
415 } elseif( $conf->License == "none" ) {
416 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
417 } else {
418 $conf->RightsUrl = importRequest( "RightsUrl", "" );
419 $conf->RightsText = importRequest( "RightsText", "" );
420 $conf->RightsCode = importRequest( "RightsCode", "" );
421 $conf->RightsIcon = importRequest( "RightsIcon", "" );
422 }
423
424 $conf->Shm = importRequest( "Shm", "none" );
425 $conf->MCServers = importRequest( "MCServers" );
426
427 /* Test memcached servers */
428
429 if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
430 $conf->MCServerArray = array_map( 'trim', explode( ',', $conf->MCServers ) );
431 foreach ( $conf->MCServerArray as $server ) {
432 $error = testMemcachedServer( $server );
433 if ( $error ) {
434 $errs["MCServers"] = $error;
435 break;
436 }
437 }
438 } else if ( $conf->Shm == 'memcached' ) {
439 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
440 }
441
442 /* default values for installation */
443 $conf->Email =importRequest("Email", "email_enabled");
444 $conf->Emailuser=importRequest("Emailuser", "emailuser_enabled");
445 $conf->Enotif =importRequest("Enotif", "enotif_allpages");
446 $conf->Eauthent =importRequest("Eauthent", "eauthent_enabled");
447
448 if( $conf->posted && ( 0 == count( $errs ) ) ) {
449 do { /* So we can 'continue' to end prematurely */
450 $conf->Root = ($conf->RootPW != "");
451
452 /* Load up the settings and get installin' */
453 $local = writeLocalSettings( $conf );
454 $wgCommandLineMode = false;
455 chdir( ".." );
456 eval($local);
457 if (!in_array($conf->DBtype, array("mysql", "oracle"))) {
458 $errs["DBtype"] = "Unknown database type.";
459 continue;
460 }
461 print "<li>Database type: {$conf->DBtype}</li>\n";
462 $dbclass = 'Database'.ucfirst($conf->DBtype);
463 require_once("$dbclass.php");
464 $wgDBtype = $conf->DBtype;
465 $wgDBadminuser = "root";
466 $wgDBadminpassword = $conf->RootPW;
467 $wgDBprefix = $conf->DBprefix;
468 $wgCommandLineMode = true;
469 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
470 require_once( "includes/Setup.php" );
471 chdir( "config" );
472
473 require_once( "maintenance/InitialiseMessages.inc" );
474
475 $wgTitle = Title::newFromText( "Installation script" );
476 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
477 if( $mysqlOldClient ) {
478 print "<li><b>PHP is linked with old MySQL client libraries. If you are
479 using a MySQL 4.1 server and have problems connecting to the database,
480 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
481 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
482 }
483 $dbc = new $dbclass;
484 if ($conf->DBtype == 'mysql') {
485 print "<li>Trying to connect to database server on $wgDBserver as root...\n";
486 $wgDatabase = $dbc->newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
487
488 if( $wgDatabase->isOpen() ) {
489 $myver = get_db_version();
490 $wgDatabase->ignoreErrors(true);
491 $conf->Root = true;
492 print "<ul><li>Connected as root (automatic)</li></ul></li>\n";
493 } else {
494 print "<ul><li>MySQL error " . ($err = mysql_errno() ) .
495 ": " . htmlspecialchars( mysql_error() ) . "</li></ul></li>";
496 $ok = false;
497 switch( $err ) {
498 case 1045:
499 case 2000:
500 if( $conf->Root ) {
501 $errs["RootPW"] = "Check password";
502 } else {
503 print "<li>Trying regular user...\n";
504 /* Try the regular user... */
505 $wgDBadminuser = $wgDBuser;
506 $wgDBadminpassword = $wgDBpassword;
507 /* Wait one second for connection rate limiting, present on some systems */
508 sleep(1);
509 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
510 if( !$wgDatabase->isOpen() ) {
511 print "<ul><li>MySQL error " . ($err = mysql_errno() ) .
512 ": " . htmlspecialchars( mysql_error() ) . "</li></ul></li>";
513 $errs["DBuser"] = "Check name/pass";
514 $errs["DBpassword"] = "or enter root";
515 $errs["DBpassword2"] = "password below";
516 $errs["RootPW"] = "Got root?";
517 } else {
518 $myver = mysql_get_server_info( $wgDatabase->mConn );
519 $wgDatabase->ignoreErrors(true);
520 $conf->Root = false;
521 $conf->RootPW = "";
522 print " ok.</li>\n";
523 # And keep going...
524 $ok = true;
525 }
526 break;
527 }
528 case 2002:
529 case 2003:
530 $errs["DBserver"] = "Connection failed";
531 break;
532 default:
533 $errs["DBserver"] = "Couldn't connect to database";
534 break;
535 }
536 if( !$ok ) continue;
537 }
538 } else /* not mysql */ {
539 print "<li>Connecting to SQL server...";
540 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
541 if (!$wgDatabase->isOpen()) {
542 print " error: " . $wgDatabase->lastError() . "</li>\n";
543 } else {
544 $wgDatabase->ignoreErrors(true);
545 $myver = get_db_version();
546 }
547 }
548
549 if ( !$wgDatabase->isOpen() ) {
550 $errs["DBserver"] = "Couldn't connect to database";
551 continue;
552 }
553
554 print "<li>Connected to $myver";
555 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
556 print "; enabling MySQL 4 enhancements";
557 $conf->DBmysql4 = true;
558 $local = writeLocalSettings( $conf );
559 }
560 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
561 if( $mysqlNewAuth && $mysqlOldClient ) {
562 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
563 to old client libraries; if you have trouble with authentication, see
564 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
565 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
566 }
567 print "</li>\n";
568
569 if ($conf->DBtype == 'mysql') {
570 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
571 if( $sel ) {
572 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
573 } else {
574 $err = mysql_errno();
575 if ( $err != 1049 ) {
576 print "<ul><li>Error selecting database $wgDBname: $err " .
577 htmlspecialchars( mysql_error() ) . "</li></ul>";
578 continue;
579 }
580 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
581 if( !$res ) {
582 print "<li>Couldn't create database <tt>" .
583 htmlspecialchars( $wgDBname ) .
584 "</tt>; try with root access or check your username/pass.</li>\n";
585 $errs["RootPW"] = "&lt;- Enter";
586 continue;
587 }
588 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
589 }
590 $wgDatabase->selectDB( $wgDBname );
591 }
592
593
594 if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
595 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
596
597 # Create user if required
598 if ( $conf->Root ) {
599 $conn = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
600 if ( $conn->isOpen() ) {
601 print "<li>DB user account ok</li>\n";
602 $conn->close();
603 } else {
604 print "<li>Granting user permissions...";
605 if( $mysqlOldClient && $mysqlNewAuth ) {
606 print " <b class='error'>If the next step fails, see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
607 }
608 print "</li>\n";
609 dbsource( "../maintenance/users.sql", $wgDatabase );
610 }
611 }
612 print "<pre>\n";
613 chdir( ".." );
614 flush();
615 do_all_updates();
616 chdir( "config" );
617
618 print "</pre>\n";
619 print "<li>Finished update checks.</li>\n";
620 } else {
621 # FIXME: Check for errors
622 print "<li>Creating tables...";
623 if ($conf->DBtype == 'mysql') {
624 dbsource( "../maintenance/tables.sql", $wgDatabase );
625 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
626 } else {
627 dbsource( "../maintenance/oracle/tables.sql", $wgDatabase );
628 dbsource( "../maintenance/oracle/interwiki.sql", $wgDatabase );
629 }
630
631 print " done.</li>\n";
632
633 print "<li>Initializing data...";
634 $wgDatabase->insert( 'site_stats',
635 array( 'ss_row_id' => 1,
636 'ss_total_views' => 0,
637 'ss_total_edits' => 0,
638 'ss_good_articles' => 0 ) );
639 # setting up the db user
640 if( $conf->Root ) {
641 print "<li>Granting user permissions...</li>\n";
642 dbsource( "../maintenance/users.sql", $wgDatabase );
643 }
644
645 if( $conf->SysopName ) {
646 $u = User::newFromName( $conf->getSysopName() );
647 if ( 0 == $u->idForName() ) {
648 $u->addToDatabase();
649 $u->setPassword( $conf->getSysopPass() );
650 $u->saveSettings();
651
652 $u->addGroup( "sysop" );
653 $u->addGroup( "bureaucrat" );
654
655 print "<li>Created sysop account <tt>" .
656 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
657 } else {
658 print "<li>Could not create user - already exists!</li>\n";
659 }
660 } else {
661 print "<li>Skipped sysop account creation, no name given.</li>\n";
662 }
663
664 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
665 $article = new Article( $titleobj );
666 $newid = $article->insertOn( $wgDatabase );
667 $revision = new Revision( array(
668 'page' => $newid,
669 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
670 'comment' => '',
671 'user' => 0,
672 'user_text' => 'MediaWiki default',
673 ) );
674 $revid = $revision->insertOn( $wgDatabase );
675 $article->updateRevisionOn( $wgDatabase, $revision );
676
677 print "<li><pre>";
678 initialiseMessages();
679 print "</pre></li>\n";
680 }
681
682 /* Write out the config file now that all is well */
683 print "<p>Creating LocalSettings.php...</p>\n\n";
684 $localSettings = "<" . "?php$endl$local$endl?" . ">";
685 // Fix up a common line-ending problem (due to CVS on Windows)
686 $localSettings = str_replace( "\r\n", "\n", $localSettings );
687
688 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
689 $xt = "xt"; # Refuse to overwrite an existing file
690 } else {
691 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
692 }
693 $f = fopen( "LocalSettings.php", $xt );
694
695 if( $f == false ) {
696 dieout( "<p>Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
697 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
698 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
699 }
700 if(fwrite( $f, $localSettings ) ) {
701 fclose( $f );
702 writeSuccessMessage();
703 } else {
704 fclose( $f );
705 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
706
707 }
708
709 } while( false );
710 }
711 ?>
712 </ul>
713
714
715 <?php
716
717 if( count( $errs ) ) {
718 /* Display options form */
719
720 if( $conf->posted ) {
721 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
722 }
723 ?>
724
725 <form action="index.php" name="config" method="post">
726
727
728 <h2>Site config</h2>
729
730 <dl class="setup">
731 <dd>
732 <?php
733 aField( $conf, "Sitename", "Site name:" );
734 ?>
735 </dd>
736 <dt>
737 Your site name should be a relatively short word. It'll appear as the namespace
738 name for 'meta' pages as well as throughout the user interface. Good site names
739 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
740 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
741 which may cause problems.
742 </dt>
743
744 <dd>
745 <?php
746 aField( $conf, "EmergencyContact", "Contact e-mail" );
747 ?>
748 </dd>
749 <dt>
750 This will be used as the return address for password reminders and
751 may be displayed in some error conditions so visitors can get in
752 touch with you. It is also be used as the default sender address of e-mail
753 notifications (enotifs).
754 </dt>
755
756 <dd>
757 <label class='column' for="LanguageCode">Language</label>
758 <select id="LanguageCode" name="LanguageCode">
759
760 <?php
761 $list = getLanguageList();
762 foreach( $list as $code => $name ) {
763 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
764 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
765 }
766 ?>
767 </select>
768 </dd>
769 <dt>
770 You may select the language for the user interface of the wiki...
771 Some localizations are less complete than others. Unicode (UTF-8 encoding)
772 is used for all localizations.
773 </dt>
774
775 <dd>
776 <label class='column'>Copyright/license metadata</label>
777 <div>Select one:</div>
778
779 <ul class="plain">
780 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
781 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
782 <li><?php
783 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
784 $partner = "MediaWiki";
785 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
786 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
787 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
788 print "<a href=\"$ccApp\">choose</a>";
789 ?> (link will wipe out any other data in this form!)
790 <?php if( $conf->License == "cc" ) { ?>
791 <ul>
792 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon' />", "hidden" ); ?></li>
793 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
794 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
795 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
796 </ul>
797 <?php } ?>
798 </li>
799 </ul>
800 </dd>
801 <dt>
802 MediaWiki can include a basic license notice, icon, and machine-readable
803 copyright metadata if your wiki's content is to be licensed under
804 the GNU FDL or a Creative Commons license. If you're not sure, leave
805 it at "none".
806 </dt>
807
808
809 <dd>
810 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
811 </dd>
812 <dd>
813 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
814 </dd>
815 <dd>
816 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
817 </dd>
818 <dt>
819 A sysop user account can lock or delete pages, block problematic IP
820 addresses from editing, and other maintenance tasks. If creating a new
821 wiki database, a sysop account will be created with the given name
822 and password.
823 </dt>
824
825 <dd>
826 <label class='column'>Shared memory caching</label>
827 <div>Select one:</div>
828
829 <ul class="plain">
830 <li><?php aField( $conf, "Shm", "no caching", "radio", "none" ); ?></li>
831 <?php
832 if ( $conf->turck ) {
833 echo "<li>";
834 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
835 echo "</li>";
836 }
837 ?>
838 <?php
839 if ( $conf->eaccel ) {
840 echo "<li>";
841 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
842 echo "</li>";
843 }
844 ?>
845 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
846 <li><?php aField( $conf, "MCServers", "Memcached servers", "" ) ?></li>
847 </ul>
848 </dd>
849 <dt>
850 Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed
851 up MediaWiki significantly. Memcached is the best solution but needs to be
852 installed. Specify the server addresses and ports in a comma-separted list. Only
853 use Turck shared memory if the wiki will be running on a single Apache server.
854 </dl>
855
856 <h2>E-mail, e-mail notification and authentication setup</h2>
857
858 <dl class="setup">
859 <dd>
860 <label class='column'>E-mail (general)</label>
861 <div>Select one:</div>
862
863 <ul class="plain">
864 <li><?php aField( $conf, "Email", "enabled", "radio", "email_enabled" ); ?></li>
865 <li><?php aField( $conf, "Email", "disabled", "radio", "email_disabled" ); ?></li>
866 </ul>
867 </dd>
868 <dt>
869 Use this to disable all e-mail functions (send a password reminder, user-to-user e-mail and e-mail notification),
870 if sending e-mails on your server doesn't work.
871 </dt>
872 <dd>
873 <label class='column'>User-to-user e-mail</label>
874 <div>Select one:</div>
875
876 <ul class="plain">
877 <li><?php aField( $conf, "Emailuser", "enabled", "radio", "emailuser_enabled" ); ?></li>
878 <li><?php aField( $conf, "Emailuser", "disabled", "radio", "emailuser_disabled" ); ?></li>
879 </ul>
880 </dd>
881 <dt>
882 Use this to disable only the user-to-user e-mail function (EmailUser).
883 </dt>
884 <dd>
885 <label class='column'>E-mail notification</label>
886 <div>Select one:</div>
887
888 <ul class="plain">
889 <li><?php aField( $conf, "Enotif", "disabled", "radio", "enotif_disabled" ); ?></li>
890 <li><?php aField( $conf, "Enotif", "enabled for changes of watch-listed and user_talk pages (recommended for small wikis; perhaps not suited for large wikis)", "radio", "enotif_allpages" ); ?></li>
891 <li><?php aField( $conf, "Enotif", "enabled for changes of user_talk pages only (suited for small and large wikis)", "radio", "enotif_usertalk" ); ?></li>
892 </ul>
893 </dd>
894 <dt>
895 <p>
896 E-mail notification sends a notification e-mail to a user, when the user_talk page is changed
897 and/or when watch-listed pages are changed, depending on the above settings.
898 When testing this feature, be reminded, that obviously an e-mail address must be present in your preferences
899 and that your own changes never trigger notifications to be sent to yourself.</p>
900
901 <p>Users get corresponding options to select or deselect in their users' preferences.
902 The user options are not shown on the preference page, if e-mail notification is disabled.</p>
903
904 <p>There are additional options for fine tuning in /includes/DefaultSettings.php .</p>
905 </dt>
906
907 <dd>
908 <label class='column'>E-mail address authentication</label>
909 <div>Select one:</div>
910
911 <ul class="plain">
912 <li><?php aField( $conf, "Eauthent", "disabled", "radio", "eauthent_disabled" ); ?></li>
913 <li><?php aField( $conf, "Eauthent", "enabled", "radio", "eauthent_enabled" ); ?></li>
914 </ul>
915 </dd>
916 <dt>
917 <p>
918 E-mail address authentication uses a scheme to authenticate e-mail addresses of the users. The user who initially enters or who changes his/her stored e-mail address
919 gets a one-time temporary password mailed to that address. The user can use the original password as long as wanted, however, the stored e-mail address
920 is only authenticated at the moment when the user logs in with the one-time temporary password.<p>
921
922 <p>The e-mail address stays authenticated as long as the user does not change it; the time of authentication is indicated
923 on the user preference page.</p>
924
925 <p>If the option is enabled, only authenticated e-mail addresses can receive EmailUser mails and/or
926 e-mail notification mails.</p>
927 </dt>
928
929 </dl>
930
931 <h2>Database config</h2>
932
933 <dl class="setup">
934 <dd>
935 <label class='column'>Database type</label>
936 <div>Select the database server software:</div>
937 <ul class='plain'>
938 <?php
939 aField( $conf, "DBtype", "MySQL", "radio", "mysql");
940 aField( $conf, "DBtype", "Oracle", "radio", "oracle" );
941 ?>
942 </ul>
943 </dd>
944
945 <dd><?php
946 aField( $conf, "DBserver", "SQL server host" );
947 ?></dd>
948 <dt>
949 If your database server isn't on your web server, enter the name
950 or IP address here. MySQL only.
951 </dt>
952
953 <dd><?php
954 aField( $conf, "DBname", "Database name" );
955 ?></dd>
956 <dt>
957 If using Oracle, set this to your connection identifier.
958 </dt>
959 <dd><?php
960 aField( $conf, "DBuser", "DB username" );
961 ?></dd>
962 <dd><?php
963 aField( $conf, "DBpassword", "DB password", "password" );
964 ?></dd>
965 <dd><?php
966 aField( $conf, "DBpassword2", "again", "password" );
967 ?></dd>
968 <dt>
969 If you only have a single user account and database available,
970 enter those here. If you have database root access (see below)
971 you can specify new accounts/databases to be created.
972 </dt>
973
974 <dd><?php
975 aField( $conf, "DBprefix", "Database table prefix" );
976 ?></dd>
977 <dt>
978 <p>If you need to share one database between multiple wikis, or
979 MediaWiki and another web application, you may choose to
980 add a prefix to all the table names to avoid conflicts.</p>
981
982 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
983 </dt>
984
985 <dd>
986 <?php
987 aField( $conf, "RootPW", "DB root password", "password" );
988 ?>
989 </dd>
990 <dt>
991 You will only need this if the database and/or user account
992 above don't already exist.
993 Do <em>not</em> type in your machine's root password! MySQL
994 has its own "root" user with a separate password. (It might
995 even be blank, depending on your configuration.)
996 </dt>
997
998 <dd>
999 <label class='column'>&nbsp;</label>
1000 <input type="submit" value="Install!" />
1001 </dd>
1002 </dl>
1003
1004
1005 </form>
1006
1007 <?php
1008 }
1009
1010 /* -------------------------------------------------------------------------------------- */
1011 function writeSuccessMessage() {
1012 global $conf;
1013 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1014 echo <<<EOT
1015 <p>Installation successful!</p>
1016 <p>To complete the installation, please do the following:
1017 <ol>
1018 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1019 <li>Upload it to the parent directory</li>
1020 <li>Delete config/LocalSettings.php</li>
1021 <li>Start using <a href='../index.php'>your wiki</a>!
1022 </ol>
1023 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1024 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1025 which means that anyone on the same server can read your database password! Downloading
1026 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1027 EOT;
1028 } else {
1029 echo "<p>Installation successful! Move the config/LocalSettings.php file into the parent directory, then follow
1030 <a href='../index.php'>this link</a> to your wiki.</p>\n";
1031 }
1032 }
1033
1034
1035 function escapePhpString( $string ) {
1036 return strtr( $string,
1037 array(
1038 "\n" => "\\n",
1039 "\r" => "\\r",
1040 "\t" => "\\t",
1041 "\\" => "\\\\",
1042 "\$" => "\\\$",
1043 "\"" => "\\\""
1044 ));
1045 }
1046
1047 function writeLocalSettings( $conf ) {
1048 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
1049 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
1050 $conf->PasswordSender = $conf->EmergencyContact;
1051 $zlib = ($conf->zlib ? "" : "# ");
1052 $magic = ($conf->ImageMagick ? "" : "# ");
1053 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1054 $pretty = ($conf->prettyURLs ? "" : "# ");
1055 $ugly = ($conf->prettyURLs ? "# " : "");
1056 $rights = ($conf->RightsUrl) ? "" : "# ";
1057 $hashedUploads = $conf->safeMode ? '' : '# ';
1058
1059 switch ( $conf->Shm ) {
1060 case 'memcached':
1061 $cacheType = 'CACHE_MEMCACHED';
1062 $mcservers = var_export( $conf->MCServerArray, true );
1063 break;
1064 case 'turck':
1065 case 'eaccel':
1066 $cacheType = 'CACHE_ACCEL';
1067 $mcservers = 'array()';
1068 break;
1069 default:
1070 $cacheType = 'CACHE_NONE';
1071 $mcservers = 'array()';
1072 }
1073
1074 if ( $conf->Email == 'email_enabled' ) {
1075 $enableemail = 'true';
1076 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
1077 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
1078 switch ( $conf->Enotif ) {
1079 case 'enotif_usertalk':
1080 $enotifusertalk = 'true';
1081 $enotifwatchlist = 'false';
1082 break;
1083 case 'enotif_allpages':
1084 $enotifusertalk = 'true';
1085 $enotifwatchlist = 'true';
1086 break;
1087 default:
1088 $enotifusertalk = 'false';
1089 $enotifwatchlist = 'false';
1090 }
1091 } else {
1092 $enableuseremail = 'false';
1093 $enableemail = 'false';
1094 $eauthent = 'false';
1095 $enotifusertalk = 'false';
1096 $enotifwatchlist = 'false';
1097 }
1098
1099 $file = @fopen( "/dev/urandom", "r" );
1100 if ( $file ) {
1101 $secretKey = bin2hex( fread( $file, 32 ) );
1102 fclose( $file );
1103 } else {
1104 $secretKey = "";
1105 for ( $i=0; $i<8; $i++ ) {
1106 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1107 }
1108 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1109 }
1110
1111 # Add slashes to strings for double quoting
1112 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1113 if( $conf->License == 'gfdl' ) {
1114 # Needs literal string interpolation for the current style path
1115 $slconf['RightsIcon'] = $conf->RightsIcon;
1116 }
1117
1118 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
1119 $localsettings = "
1120 # This file was automatically generated by the MediaWiki installer.
1121 # If you make manual changes, please keep track in case you need to
1122 # recreate them later.
1123
1124 \$IP = \"{$slconf['IP']}\";
1125 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1126 require_once( \"includes/DefaultSettings.php\" );
1127
1128 # If PHP's memory limit is very low, some operations may fail.
1129 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1130
1131 if ( \$wgCommandLineMode ) {
1132 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1133 die( \"This script must be run from the command line\\n\" );
1134 }
1135 } elseif ( empty( \$wgNoOutputBuffer ) ) {
1136 ## Compress output if the browser supports it
1137 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1138 }
1139
1140 \$wgSitename = \"{$slconf['Sitename']}\";
1141
1142 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1143 \$wgScript = \"\$wgScriptPath/index.php\";
1144 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1145
1146 ## If using PHP as a CGI module, use the ugly URLs
1147 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1148 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1149
1150 \$wgStylePath = \"\$wgScriptPath/skins\";
1151 \$wgStyleDirectory = \"\$IP/skins\";
1152 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1153
1154 \$wgUploadPath = \"\$wgScriptPath/images\";
1155 \$wgUploadDirectory = \"\$IP/images\";
1156
1157 \$wgEnableEmail = $enableemail;
1158 \$wgEnableUserEmail = $enableuseremail;
1159
1160 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1161 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1162
1163 ## For a detailed description of the following switches see
1164 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1165 ## There are many more options for fine tuning available see
1166 ## /includes/DefaultSettings.php
1167 ## UPO means: this is also a user preference option
1168 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1169 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1170 \$wgEmailAuthentication = $eauthent;
1171
1172 \$wgDBserver = \"{$slconf['DBserver']}\";
1173 \$wgDBname = \"{$slconf['DBname']}\";
1174 \$wgDBuser = \"{$slconf['DBuser']}\";
1175 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1176 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1177 \$wgDBtype = \"{$slconf['DBtype']}\";
1178
1179 # If you're on MySQL 3.x, this next line must be FALSE:
1180 \$wgDBmysql4 = {$conf->DBmysql4};
1181
1182 ## Shared memory settings
1183 \$wgMainCacheType = $cacheType;
1184 \$wgMemCachedServers = $mcservers;
1185
1186 ## To enable image uploads, make sure the 'images' directory
1187 ## is writable, then uncomment this:
1188 # \$wgEnableUploads = true;
1189 \$wgUseImageResize = {$conf->UseImageResize};
1190 {$magic}\$wgUseImageMagick = true;
1191 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1192
1193 ## If you want to use image uploads under safe mode,
1194 ## create the directories images/archive, images/thumb and
1195 ## images/temp, and make them all writable. Then uncomment
1196 ## this, if it's not already uncommented:
1197 {$hashedUploads}\$wgHashedUploadDirectory = false;
1198
1199 ## If you have the appropriate support software installed
1200 ## you can enable inline LaTeX equations:
1201 # \$wgUseTeX = true;
1202 \$wgMathPath = \"{\$wgUploadPath}/math\";
1203 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1204 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1205
1206 \$wgLocalInterwiki = \$wgSitename;
1207
1208 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1209
1210 \$wgProxyKey = \"$secretKey\";
1211
1212 ## Default skin: you can change the default skin. Use the internal symbolic
1213 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1214 # \$wgDefaultSkin = 'monobook';
1215
1216 ## For attaching licensing metadata to pages, and displaying an
1217 ## appropriate copyright notice / icon. GNU Free Documentation
1218 ## License and Creative Commons licenses are supported so far.
1219 {$rights}\$wgEnableCreativeCommonsRdf = true;
1220 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1221 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1222 \$wgRightsText = \"{$slconf['RightsText']}\";
1223 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1224 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1225
1226 \$wgDiff3 = \"{$slconf['diff3']}\";
1227 ";
1228 // Keep things in Unix line endings internally;
1229 // the system will write out as local text type.
1230 return str_replace( "\r\n", "\n", $localsettings );
1231 }
1232
1233 function dieout( $text ) {
1234 die( $text . "\n\n</body>\n</html>" );
1235 }
1236
1237 function importVar( &$var, $name, $default = "" ) {
1238 if( isset( $var[$name] ) ) {
1239 $retval = $var[$name];
1240 if ( get_magic_quotes_gpc() ) {
1241 $retval = stripslashes( $retval );
1242 }
1243 } else {
1244 $retval = $default;
1245 }
1246 return $retval;
1247 }
1248
1249 function importPost( $name, $default = "" ) {
1250 return importVar( $_POST, $name, $default );
1251 }
1252
1253 function importRequest( $name, $default = "" ) {
1254 return importVar( $_REQUEST, $name, $default );
1255 }
1256
1257 function aField( &$conf, $field, $text, $type = "", $value = "" ) {
1258 if( $type != "" ) {
1259 $xtype = "type=\"$type\"";
1260 } else {
1261 $xtype = "";
1262 }
1263
1264 if(!(isset($id)) or ($id == "") ) $id = $field;
1265 $nolabel = ($type == "radio") || ($type == "hidden");
1266 if( $nolabel ) {
1267 echo "\t\t<label>";
1268 } else {
1269 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1270 }
1271
1272 if( $type == "radio" && $value == $conf->$field ) {
1273 $checked = "checked='checked'";
1274 } else {
1275 $checked = "";
1276 }
1277 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\"";
1278 if( $type == "radio" ) {
1279 echo htmlspecialchars( $value );
1280 } else {
1281 echo htmlspecialchars( $conf->$field );
1282 }
1283 echo "\" />\n";
1284 if( $nolabel ) {
1285 echo " $text</label>\n";
1286 }
1287
1288 global $errs;
1289 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1290 }
1291
1292 function getLanguageList() {
1293 global $wgLanguageNames;
1294 if( !isset( $wgLanguageNames ) ) {
1295 $wgContLanguageCode = "xxx";
1296 function wfLocalUrl( $x ) { return $x; }
1297 function wfLocalUrlE( $x ) { return $x; }
1298 require_once( "languages/Names.php" );
1299 }
1300
1301 $codes = array();
1302
1303 $d = opendir( "../languages" );
1304 while( false !== ($f = readdir( $d ) ) ) {
1305 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1306 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1307 if( isset( $wgLanguageNames[$code] ) ) {
1308 $name = $code . ' - ' . $wgLanguageNames[$code];
1309 } else {
1310 $name = $code;
1311 }
1312 $codes[$code] = $name;
1313 }
1314 }
1315 closedir( $d );
1316 ksort( $codes );
1317 return $codes;
1318 }
1319
1320 #Check for location of an executable
1321 # @param string $loc single location to check
1322 # @param array $names filenames to check for.
1323 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1324 function locate_executable($loc, $names, $versioninfo = false) {
1325 if (!is_array($names))
1326 $names = array($names);
1327
1328 foreach ($names as $name) {
1329 if (file_exists("$loc/$name")) {
1330 if (!$versioninfo)
1331 return "$loc/$name";
1332
1333 $file = str_replace('$1', "$loc/$name", $versioninfo[0]);
1334 if (strstr(`$file`, $versioninfo[1]) !== false)
1335 return "$loc/$name";
1336 }
1337 }
1338 return false;
1339 }
1340
1341 function get_db_version() {
1342 global $wgDatabase, $conf;
1343 if ($conf->DBtype == 'mysql')
1344 return mysql_get_server_info( $wgDatabase->mConn );
1345 else if ($conf->DBtype == 'oracle')
1346 return oci_server_version($wgDatabase->mConn);
1347 }
1348
1349 # Test a memcached server
1350 function testMemcachedServer( $server ) {
1351 $hostport = explode(":", $server);
1352 $errstr = false;
1353 $fp = false;
1354 if ( !function_exists( 'fsockopen' ) ) {
1355 $errstr = "Can't connect to memcached, fsockopen() not present";
1356 }
1357 if ( !$errstr && count( $hostport ) != 2 ) {
1358 $errstr = 'Please specify host and port';
1359 var_dump( $hostport );
1360 }
1361 if ( !$errstr ) {
1362 list( $host, $port ) = $hostport;
1363 $errno = 0;
1364 $fsockerr = '';
1365
1366 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
1367 if ( $fp === false ) {
1368 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1369 }
1370 }
1371 if ( !$errstr ) {
1372 $command = "version\r\n";
1373 $bytes = fwrite( $fp, $command );
1374 if ( $bytes != strlen( $command ) ) {
1375 $errstr = "Cannot write to memcached socket on $host:$port";
1376 }
1377 }
1378 if ( !$errstr ) {
1379 $expected = "VERSION ";
1380 $response = fread( $fp, strlen( $expected ) );
1381 if ( $response != $expected ) {
1382 $errstr = "Didn't get correct memcached response from $host:$port";
1383 }
1384 }
1385 if ( $fp ) {
1386 fclose( $fp );
1387 }
1388 if ( !$errstr ) {
1389 echo "<li>Connected to memcached on $host:$port successfully";
1390 }
1391 return $errstr;
1392 }
1393 ?>
1394
1395 </body>
1396 </html>